<template>
  <UView name="寄存器点位">
    <UViewSearch v-model="searchModel">
      <URow col="search">
        <UInput field="name" label="点位名称" :allowClear="true"/>
        <UInput field="fieldName" label="点位字段名称" :allowClear="true"/>
        <UInput field="fieldType" label="字段类型" :allowClear="true"/>
        <UFuncBtn func="query" url="/iot/pointPosition/view">搜索</UFuncBtn>
        <UFuncBtn func="reset">重置</UFuncBtn>
        <UFuncBtn func="add" url="/iot/pointPosition/add" v-auth="'iot:pointPosition:add'">新增</UFuncBtn>
      </URow>
    </UViewSearch>
    <UViewModal title="寄存器点位管理" :span="[7, 14]" v-model="editModel" :rules="rules">
      <template #default="{model}">
        <UInput field="name" label="点位名称" />
        <UInput field="address" label="点位地址" />
        <UInputNumber field="modelId" label="型号id" />
        <UInput field="fieldName" label="点位字段名称" />
        <UInput field="fieldType" label="字段类型" />
      </template>
      <template #footer>
        <UFuncBtn func="cancel">取消</UFuncBtn>
        <UFuncBtn func="submit" url="/iot/pointPosition/saveOrUpdate">提交</UFuncBtn>
        <UFuncBtn func="reset">重置</UFuncBtn>
      </template>
    </UViewModal>
    <UViewTable :columns="columns">
      <template #action="{record}">
        <UFuncTag func="edit" :data="record" url="/iot/pointPosition/edit" v-auth="'iot:pointPosition:edit'">修改</UFuncTag>
        <UFuncTag func="del" :data="record" url="/iot/pointPosition/del" v-auth="'iot:pointPosition:del'">删除</UFuncTag>
      </template>
    </UViewTable>
  </UView>
</template>
<!-- 寄存器点位功能 -->
<script>
import {ref, reactive} from "vue";
export default {
  name: "PointPosition",
  setup() {
    let columns = ref([
          {field: "name", title: "点位名称"},
          {field: "address", title: "点位地址"},
          {field: "modelId", title: "型号id"},
          {field: "fieldName", title: "点位字段名称"},
          {field: "fieldType", title: "字段类型"},
          {field: "createTime", title: ""},
          {field: 'action', title: '操作', type: 'action'},
      ]);

    let rules = reactive({
        name: {required: true, message: '点位名称必填'},
        address: {required: true, message: '点位地址必填'},
        modelId: {required: true, message: '型号id必填'},
        fieldName: {required: true, message: '点位字段名称必填'},
        createTime: {required: true, message: '必填'},
    })

    let editModel = ref({});
    let searchModel = ref({});
    return {columns, rules, editModel, searchModel}
  },
}
</script>
<style scoped> </style>